package com.triones.api.controller.web;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.triones.api.entity.GuideDO;
import com.triones.api.entity.vo.GuideVO;
import com.triones.api.service.AppManageService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * app管理
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/appMgt")
public class AppManageController extends BaseController {

    private final AppManageService appManageService;

    /**
     * 新增导航页
     */
    @SaCheckPermission("system:guide:handle")
    @Log(title = "app管理", businessType = BusinessType.INSERT)
    @PostMapping("/guide")
    public R<Void> addGuide(@Validated @RequestBody GuideDO dto) {
        return toAjax(appManageService.addGuide(dto));
    }

    /**
     * 修改导航页
     */
    @SaCheckPermission("system:guide:handle")
    @Log(title = "app管理", businessType = BusinessType.UPDATE)
    @PutMapping("/guide")
    public R<Void> editGuide(@Validated @RequestBody GuideDO dto) {
        return toAjax(appManageService.editGuide(dto));
    }

    /**
     * 获取引导页详细信息
     */
    @SaCheckPermission("system:guide:handle")
    @GetMapping(value = "/guide")
    public R<GuideVO> getGuideInfo() {
        return R.ok(appManageService.getGuideInfo());
    }
}
